package com.link2room.rodimus.controller.inside;


import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.rodimus.facade.ISalesmanApiFacadeService;
import com.link2room.rodimus.dto.param.inside.FindSalesmanBySalesmanNoPararmDto;
import com.link2room.rodimus.dto.param.inside.SalesmanAwardMemberInsideParamDto;
import com.link2room.rodimus.dto.param.inside.SalesmanInComeDetailInsideParamDto;
import com.link2room.rodimus.facade.ISalesmanInsideFacadeService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created by VegetaKo on 2016/9/25.
 */
@Api(tags = "分销员相关")
@RestController
@RequestMapping("/in/Salesmans")
public class SalseManInsideController {

    @Resource
    private ISalesmanApiFacadeService salesmanFacadeService;
    @Resource
    private ISalesmanInsideFacadeService salesmanInsideFacadeService;

    @RequestMapping(value = "/Award",method = RequestMethod.POST)
    public BaseResultDto awardSalesmanReservation(
            @RequestBody SalesmanInComeDetailInsideParamDto salesmanInComeDetailInsideParamDto
    ) throws Exception {
        salesmanFacadeService.awardSalesmanReservation(salesmanInComeDetailInsideParamDto);
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        return baseResultDto;
    }

    @RequestMapping(value = "/Awards/Member",method = RequestMethod.POST)
    public BaseResultDto awardSalesmanMember(
            @RequestBody SalesmanAwardMemberInsideParamDto salesmanAwardMemberInsideParamDto
    ) throws Exception {
        salesmanFacadeService.awardSalesmanMember(salesmanAwardMemberInsideParamDto);
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        return baseResultDto;
    }

    @RequestMapping(value = "/MappingEmployee",method = RequestMethod.GET)
    public BaseResultDto mappingEmployee(
            @RequestParam(name = "salesmanNo")String salesmanNo
    ) throws Exception {
        FindSalesmanBySalesmanNoPararmDto pararmDto = new FindSalesmanBySalesmanNoPararmDto();
        pararmDto.setSalesmanNo(salesmanNo);
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        baseResultDto.setResultInfo(salesmanInsideFacadeService.findSalesmanBySalesmanNo(pararmDto));
        return baseResultDto;
    }
}
